#pragma once

#include "gui2d_global.h"
#include <osg/Referenced>
#include <osg/Image>
#include <QString>
#include <osg/Texture2D>
#include <osg/Geometry>
#include <osgText/Font>
#include <osgText/Text>

namespace osg
{
	template<class T> class ref_ptr;
	class Group;
}

namespace Gui2D
{
	class OsgTextExp:public osgText::Text
	{
	public:
		OsgTextExp()
		{}
		OsgTextExp(const Text& text,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):Text(text,copyop)
		{}
		osg::BoundingBox getTextBB()
		{
			return _textBB;
		}
	protected:
		virtual ~OsgTextExp(){}
	};

	class GUI2D_EXPORT OsgToolTip
	{
	public:
		static OsgToolTip& GetInstance();
		osg::Node* getOrCreateHudNode();
		void resizeViewSize(double width,double height);
		void setToolTipText(const QString& text,int x = 0,int y = 0);
		QString getToolTipText();
		void setBackgroundColor(const osg::Vec4& backgroundcolor);
		void setTextColor(const osg::Vec4& textcolor);
		void setTextSize(int textsize);
		void setBackgroundImage(osg::ref_ptr<osg::Image> image);
		void setBackgroundImage(const QString& image);
		void setBackgroundTexture(osg::ref_ptr<osg::Texture2D> btexture);
	protected:
		OsgToolTip();
		~OsgToolTip();
		osg::ref_ptr<osg::Geometry>			_backgroundGeo;
		osg::ref_ptr<osgText::Font>			_font;
		osg::ref_ptr<OsgTextExp>			_text;
		osg::ref_ptr<osg::Group>			_hudNode;
		float								_viewWidth;
		float								_viewHeight;
		osg::Vec3							_backgroundOffset;
		float								_borderUp;
		float								_borderDown;
		float								_borderLeft;
		float								_borderRight;
		static OsgToolTip*					_osgToolTip;
		QString								_textString;
	};
}